/**
 * https://leetcode.cn/problems/8Zf90G/description/
 */

class Solution {
public:
    int evalRPN(vector<string>& tokens) {
        stack<int> m;
        for(auto b: tokens){
            int leng=b.size();
            if((leng>1&&b[0]=='-')||isdigit(b[0]))
            m.push(stoi(b));
            else{
                int x=m.top();
                m.pop();
                int y=m.top();
                m.pop();
                switch(b[0]){
                    case '+' : m.push(x+y); break;
                    case '-' : m.push(y-x); break;
                    case '*' : m.push(x*y); break;
                    default : m.push(y/x);
                }
            }
        }
        return m.top();
    }
};